﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbEvalExpr : OdDbObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbEvalExpr(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbEvalExpr_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbEvalExpr obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbEvalExpr()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbEvalExpr(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbEvalExpr cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbEvalExpr_cast(OdRxObject.getCPtr(pObj));
			OdDbEvalExpr result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbEvalExpr)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbEvalExpr)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbEvalExpr)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbEvalExpr_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbEvalExpr_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbEvalExpr_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbEvalExpr createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbEvalExpr_createObject();
			OdDbEvalExpr result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbEvalExpr)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbEvalExpr)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbEvalExpr)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbEvalExpr() : this(TD_DbPINVOKE.new_OdDbEvalExpr__SWIG_1(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdDbEvalGraph getGraph(OpenMode openMode)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbEvalExpr_getGraph__SWIG_0(this.swigCPtr, (int)openMode);
			OdDbEvalGraph result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbEvalGraph)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbEvalGraph)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbEvalGraph)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbEvalGraph getGraph()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbEvalExpr_getGraph__SWIG_1(this.swigCPtr);
			OdDbEvalGraph result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbEvalGraph)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbEvalGraph)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbEvalGraph)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public uint nodeId()
		{
			uint result = TD_DbPINVOKE.OdDbEvalExpr_nodeId(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void addedToGraph(OdDbEvalGraph pGraph)
		{
			TD_DbPINVOKE.OdDbEvalExpr_addedToGraph(this.swigCPtr, OdDbEvalGraph.getCPtr(pGraph));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void removedFromGraph(OdDbEvalGraph pGraph)
		{
			TD_DbPINVOKE.OdDbEvalExpr_removedFromGraph(this.swigCPtr, OdDbEvalGraph.getCPtr(pGraph));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void adjacentNodeRemoved(uint adjNodeId)
		{
			TD_DbPINVOKE.OdDbEvalExpr_adjacentNodeRemoved(this.swigCPtr, adjNodeId);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void adjacentEdgeRemoved(uint adjEdgeNodeId)
		{
			TD_DbPINVOKE.OdDbEvalExpr_adjacentEdgeRemoved(this.swigCPtr, adjEdgeNodeId);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void adjacentEdgeAdded(uint fromId, uint toId, bool isInvertible)
		{
			TD_DbPINVOKE.OdDbEvalExpr_adjacentEdgeAdded(this.swigCPtr, fromId, toId, isInvertible);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void movedFromGraph(OdDbEvalGraph pFromGraph)
		{
			TD_DbPINVOKE.OdDbEvalExpr_movedFromGraph(this.swigCPtr, OdDbEvalGraph.getCPtr(pFromGraph));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void movedIntoGraph(OdDbEvalGraph pIntoGraph)
		{
			TD_DbPINVOKE.OdDbEvalExpr_movedIntoGraph(this.swigCPtr, OdDbEvalGraph.getCPtr(pIntoGraph));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void copiedIntoGraph(OdDbEvalGraph pIntoGraph)
		{
			TD_DbPINVOKE.OdDbEvalExpr_copiedIntoGraph(this.swigCPtr, OdDbEvalGraph.getCPtr(pIntoGraph));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isActivatable()
		{
			bool result = TD_DbPINVOKE.OdDbEvalExpr_isActivatable(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void activated(OdDbEvalNodeIdArray argumentActiveList)
		{
			TD_DbPINVOKE.OdDbEvalExpr_activated(this.swigCPtr, OdDbEvalNodeIdArray.getCPtr(argumentActiveList));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void graphEvalStart(bool nodeIsActive)
		{
			TD_DbPINVOKE.OdDbEvalExpr_graphEvalStart(this.swigCPtr, nodeIsActive);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void graphEvalEnd(bool nodeIsActive)
		{
			TD_DbPINVOKE.OdDbEvalExpr_graphEvalEnd(this.swigCPtr, nodeIsActive);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void graphEvalAbort(bool nodeIsActive)
		{
			TD_DbPINVOKE.OdDbEvalExpr_graphEvalAbort(this.swigCPtr, nodeIsActive);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool evaluate(OdDbEvalContext evalContext)
		{
			bool result = TD_DbPINVOKE.OdDbEvalExpr_evaluate(this.swigCPtr, OdDbEvalContext.getCPtr(evalContext));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool equals(OdDbEvalExpr pOther)
		{
			bool result = TD_DbPINVOKE.OdDbEvalExpr_equals(this.swigCPtr, OdDbEvalExpr.getCPtr(pOther));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResBuf value()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbEvalExpr_value(this.swigCPtr);
			OdResBuf result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdResult dwgInFields(OdDbDwgFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbEvalExpr_dwgInFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dwgOutFields(OdDbDwgFiler pFiler)
		{
			TD_DbPINVOKE.OdDbEvalExpr_dwgOutFields(this.swigCPtr, OdDbDwgFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdResult dxfInFields(OdDbDxfFiler pFiler)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbEvalExpr_dxfInFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void dxfOutFields(OdDbDxfFiler pFiler)
		{
			TD_DbPINVOKE.OdDbEvalExpr_dxfOutFields(this.swigCPtr, OdDbDxfFiler.getCPtr(pFiler));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult postInDatabase(OdDbDatabase arg0)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbEvalExpr_postInDatabase(this.swigCPtr, OdDbDatabase.getCPtr(arg0));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
